#pragma once

#include <iostream>

namespace facade {
    
/// @brief 具体实现子模块
class SubModuleImplementorA {
public:
    void PreRequest () {
        printf("SubModuleImplementorA::PreRequest!\n");
    }
};
class SubModuleImplementorB {
public:
    void RealRequest () {
        printf("SubModuleImplementorB::RealRequest!\n");
    }
};
class SubModuleImplementorC {
public:
    void PostRequest () {
        printf("SubModuleImplementorC::PostRequest!\n");
    }
};

/// @brief 外观角色
class Facade {
public:
    Facade() {
        implA_.reset(new SubModuleImplementorA());
        implB_.reset(new SubModuleImplementorB());
        implC_.reset(new SubModuleImplementorC());
    }

    void Request() {
        implA_->PreRequest();
        implB_->RealRequest();
        implC_->PostRequest();
    }

private:
    std::shared_ptr<SubModuleImplementorA> implA_;
    std::shared_ptr<SubModuleImplementorB> implB_;
    std::shared_ptr<SubModuleImplementorC> implC_;
};

} // namespace facade

void Test_10_facade_impl_1() {
    printf("-------------------- %s --------------------\n", __FUNCTION__);
    std::shared_ptr<facade::Facade> ptr(new facade::Facade());
    ptr->Request();
}

// -------------------- Test_10_facade_impl_1 --------------------
// SubModuleImplementorA::PreRequest!
// SubModuleImplementorB::RealRequest!
// SubModuleImplementorC::PostRequest!